using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

public class SceneClickLogic
{
    private static SceneClickLogic self;
    private ModelLocator model;
	
	GuideLogic guide;
	UISprite npcHeadPic;
    
    public static SceneClickLogic getInstance()
    {
        if (self == null)
        {
            self = new SceneClickLogic();
        }
        return self;
    }

    public SceneClickLogic()
    {
        model = ModelLocator.getInstance();
        init();
    }

    private void init()
    {
        model.addEventListener(ClientToClientFlag.CLIENT_CLICK_NPC, onClickNpc);	
	}

    private void onClickNpc(System.Object o, DispatchEventArgs e)
    {
		guide = Camera.main.GetComponent<GuideLogic>();
      	GameObject window = e.data[0] as  GameObject;
		//UITweener tw = go.GetComponent<UITweener>();
		//tw.Play(true);
		UIManagement.Instance().SetVisiable(window,GameDefine.VISIABLE);
		guide.setGuideVisible(false);
		GameObject guideRight = GameObject.Find("GuideArrow_Right");
		guide.guideMark = guideRight.transform;
		guide.setGuidePos(window,4,new Vector3(-195,-50,-20));
    }
	
	//自动寻路
    public void dispatchSceneObjClick(GameObject obj)
    {
        ModelLocator.getInstance().dispacthEvent(ClientToClientFlag.CLIENT_CLICK_SCENE_OBJ, new object[] { obj});
		if(TaskStatus.Instance().taskStatus == GameDefine.NPCStatus_UnComplete) {
			npcHeadPic = GameObject.Find("NPCHeadPic").GetComponent<UISprite>();
			npcHeadPic.spriteName = "icon_fight";
			npcHeadPic.MakePixelPerfect();
			npcHeadPic.transform.localPosition = new Vector3(2,0,0);
		}
    }
}